package cl.uchile.sketchpad.persistance.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;

import static javax.persistence.FetchType.*;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@Entity
@Table(name = "activity")
@JsonIgnoreProperties({"slides"})
public class Activity implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8006948825353879339L;
	
	private Integer id;
	private String name;
	private Date date;
	private SubjectVersion subjectVersion;
	private User author;
	
	private List<Slide> slides = new ArrayList<Slide>(0);
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public Date getDate() {
		return date;
	}
	
	public void setDate(Date date) {
		this.date = date;
	}
	
	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "subject_version_id")
	public SubjectVersion getSubjectVersion() {
		return subjectVersion;
	}
	
	public void setSubjectVersion(SubjectVersion subjectVersion) {
		this.subjectVersion = subjectVersion;
	}
	
	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "author_user_id")
	public User getAuthor() {
		return author;
	}
	
	public void setAuthor(User author) {
		this.author = author;
	}

	@OneToMany(fetch = LAZY, mappedBy = "activity")
	@OrderBy("id")
	public List<Slide> getSlides() {
		return slides;
	}

	public void setSlides(List<Slide> slides) {
		this.slides = slides;
	}
	
	

}
